<?php

require_once "data/dao/WishListDAO.php";

class WishListUtils{
	
	/**
	 * checks the database to confirm whether the user
	 * has an existing wish list or not.
	 * 
	 * @param int $id
	 * @return boolean
	 */
	public static function userHasAWishList($id){
		
		$wldao = new WishListDAO();
		
		try{
			if($wldao->getWishList($id) != null)
				return true;
		}
		catch(Exception $e){
			return false;
		}	
	}
	
	public static function gameAlreadyInWishList($gameID, $userID){
		
		$wldao = new WishListDAO();
		
		try{
			$wishList = $wldao->getWishList($userID);
			if($wishList == null)
				return false;
				
			foreach($wishList as $g){
				if($g == $gameID)
					return true;
			}
		}
		catch(Exception $e){
			return false;
		}
		return false;		
	}
	
	public static function wishListIsEmpty($userId){
		
		$wldao = new WishListDAO();
		
		try{
			$wishList = $wldao->getWishList($userId);
			if($wishList == null || ($wishList[0] == ""))
				return true;
		}
		catch(Exception $e){
			return false;
		}
		return false;
	}
}
?>
